package security;

import helpers.HashHelper;

import com.feth.play.module.pa.providers.password.SessionUsernamePasswordAuthUser;

public class ConsoleLoginUsernamePasswordAuthUser extends SessionUsernamePasswordAuthUser {

	private static final long serialVersionUID = 1L;

	final static long SESSION_TIMEOUT = 24 * 14 * 3600;

	public ConsoleLoginUsernamePasswordAuthUser(String email) {
		this(null, email);
	}

	public ConsoleLoginUsernamePasswordAuthUser(String clearPassword, String email) {
		super(clearPassword, email, System.currentTimeMillis() + 1000 * SESSION_TIMEOUT);
	}

	@Override
	protected String createPassword(String clearString) {
		return HashHelper.createPassword(clearString);
	}

	@Override
	public boolean checkPassword(String hashed, String candidate) {
		return HashHelper.validatePassword(candidate, hashed);
	}

}
